<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controller library
jimport('joomla.application.component.controller');
 
class CouponsController extends JController
{
    public function display($cachable = false, $urlparams = false) 
    {
        CouponsHelper::addSubmenu(JRequest::getCmd('view', 'coupons'));
        
        $view		= JRequest::getCmd('view', 'coupons');
        $layout 	= JRequest::getCmd('layout', 'default');
        $id		= JRequest::getInt('id');
        
        
        if ($view == 'coupon' && $layout == 'edit' && !$this->checkEditId('com_coupons.edit.coupon', $id)) 
        {
                // Somehow the person just went to the form - we don't allow that.
                $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                $this->setMessage($this->getError(), 'error');
                $this->setRedirect(JRoute::_('index.php?option=com_coupons&view=coupons', false));

                return false;
        }
        elseif($view == 'shop' && $layout == 'edit' && !$this->checkEditId('com_coupons.edit.shop', $id)) 
        {
                // Somehow the person just went to the form - we don't allow that.
                $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                $this->setMessage($this->getError(), 'error');
                $this->setRedirect(JRoute::_('index.php?option=com_coupons&view=shops', false));

                return false;
        }
        
        return parent::display($cachable, $urlparams);
    }
}
?>